package com.example.main;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main08 {
    private static final Pattern patternBody = Pattern.compile("\\{([^}]*)\\}");

    public static void main(String[] args) {
        String dir="/usr/local/{yyyyMMdd}/{yyyyMM}/{MMdd}/{yyyy}/{MM}/{dd}.csv";
        String s = parseBody(dir);
        System.out.println(s);
    }

    public static String parseBody(String body) {
        String text = body;
        Matcher m = patternBody.matcher(text);
        while (m.find()){
            String parse = m.group();
            String parseBody = parse.substring(1).substring(0, parse.length() - 2);
            String dateStr = LocalDate.now().format(DateTimeFormatter.ofPattern(parseBody));
            text = text.replace(parse, dateStr);
        }
        return text;
    }
}
